﻿using System;

namespace Haidou.Wpf.Util.Extensions
{
	/// <summary>
	/// 版本扩展
	/// </summary>
	public static class VersionExtensions
	{
		/// <summary>
		/// 缩短字符串
		/// </summary>
		/// <param name="version"></param>
		/// <returns></returns>
		public static string ToStringShort(this Version version)
		{
			string result = $"{version.Major}.{version.Minor}";

			if (version.Build > 0)
			{
				result += $".{version.Build}";
			}

			if (version.Revision > 0)
			{
				result += $".{version.Revision}";
			}

			return result;
		}
	}
}
